<template>
  <div class="waiting-info">
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">区域高度设置</el-divider>
      </div>
      <el-form-item label="内容高度">
        <el-input-number
            v-model="optionsInfo['areaHeight']"
            :min="0"
            size="small"
            class="hide-spin-button"
        />
      </el-form-item>
    </div>

    <!--号别设置-->
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">号别设置</el-divider>
      </div>
      <el-form-item class="column-area">
        <div class="title">
          <el-divider content-position="center">号别类型</el-divider>
        </div>
        <div class="options-info">
          <el-radio-group v-model="optionsInfo['registerObjNameKey']">
            <el-radio
                :label="item.dictValue"
                :value="item.dictValue"
                :key="item.dictValue"
                v-for="item in registerObjNameOptions"
            >
              {{ item.dictLabel }}
            </el-radio>
          </el-radio-group>
        </div>
      </el-form-item>
    </div>

    <!--弹层控制-->
    <div class="list-item-setting" v-for="(item,index,key) in optionsInfo['layerInfo']" :key="index">
      <div class="title-info">
        <el-divider content-position="left">
          {{ (index === 'current') ? '就诊弹层设置' : '候诊弹层设置' }}
        </el-divider>
      </div>
      <el-form-item label="遮罩的背景色" class="column-area" v-if="(index === 'current')">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['layerInfo'][index].overlayBackground"/>
      </el-form-item>

      <el-form-item label="弹层的背景色" class="column-area" v-if="(index === 'current')">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['layerInfo'][index].popupBackground"/>
      </el-form-item>

      <el-form-item label="标题">
        <el-input v-model="optionsInfo['layerInfo'][index].content" placeholder="请输入内容" size="small"/>
      </el-form-item>
      <el-form-item label="标题显示">
        <el-switch v-model="optionsInfo['layerInfo'][index]['display']"/>
      </el-form-item>

      <el-form-item label="标题字号">
        <el-input-number
            :min="14"
            size="small"
            class="hide-spin-button"
            @change="(e)=>handleChangeFontSize(e,index)"
            v-model="optionsInfo['layerInfo'][index].fontSize"
        />
      </el-form-item>
      <el-form-item label="标题字体颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['layerInfo'][index].color"/>
      </el-form-item>
      <el-form-item label="标题背景颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['layerInfo'][index].backgroundColor"/>
      </el-form-item>
      <el-form-item label="患者号字体颜色" class="column-area">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['layerInfo'][index].patientNumberColor"/>
      </el-form-item>

      <el-form-item label="患者号背景颜色" class="column-area">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['layerInfo'][index].patientNumberBackground"/>
      </el-form-item>

      <el-form-item label="患者字体颜色" class="column-area">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo['layerInfo'][index].patientColor"/>
      </el-form-item>
      <el-form-item label="患者字体大小" class="column-area" v-if="false">
        <el-input-number
            :min="14"
            size="small"
            class="hide-spin-button"
            v-model="optionsInfo['layerInfo'][index].patientFontSize"
        />
      </el-form-item>

    </div>

  </div>
</template>

<script>
import constantDic from "@/utils/vue-i18n/lang/zh-CN";
import Draggable from "vuedraggable"
import roomNameKeyEditor
  from "@sc/templateDetails/modules/homeRight/property-editor/module/scene-edit/basicInfo/roomNameKey-editor.vue";
import * as types from "@c/public/form-designer/devType/datas-types";

// **特殊**
export default {
  name: "sceneWaitingDualShare-editor",

  componentName: "sceneWaitingDualShare-editor",

  components: {
    roomNameKeyEditor,
    Draggable
  },

  mixins: [],

  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },

  inject: ['serverFieldList', 'getDesignerConfig'],

  data() {
    return {
      optionsInfo: Object(),
      constantDic: constantDic,
      predefineColors: types['predefineColors'],
    }
  },

  computed: {
    registerObjNameOptions() {
      let optionInfos = this.$store.getters['templateDetails/getRegisterObjNameOptions'];
      optionInfos.push({dictValue:"treatmentRoomName",dictLabel:"诊室名称"});
      optionInfos.push({dictValue:"deptName",dictLabel:"科室名称"});
      return this.$lodash.uniqBy(optionInfos, 'dictValue');
    }
  },

  methods: {

    handleChangeFontSize(val, type) {
      if (type === 'current') {
        this.optionsInfo['layerInfo']['waiting']['fontSize'] = val
      } else if (type === 'waiting') {
        this.optionsInfo['layerInfo']['current']['fontSize'] = val
      }
    },

    handleTotal(val) {
      let {multiple} = (this.optionModel.waitingShareCallConfig)
      this.optionModel.rowNumber = multiple * val;
      console.log(this.optionModel)
    }
  },

  // 组件的所有信息
  watch: {
    optionModel: {
      handler: function (val) {
        this.optionsInfo = val[val.config];
      },
      deep: true,
      immediate: true
    }
  }
}
</script>

<style lang="scss" scoped>
.column-area {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    width: 100% !important;
    margin-bottom: 10px;
  }

  :deep(.el-form-item__content) {
    width: 100%;
    margin-left: 0 !important;

    .el-radio-group {
      width: 100%;
      display: flex;
      flex-direction: column;

      .el-radio {
        margin-bottom: 10px;
      }
    }
  }

}
</style>